Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

17.9 Scheduling Task Statistics and Pressure Stall Information Function Configuration

Linux provides a dedicated module named sched_schedstats to maintain comprehensive task scheduling statistics. Utilizing dynamic jump label techniques, this logging subsystem can be enabled or disabled at runtime with negligible overhead. The function init_schedstats() manages this toggle through a global boolean tracking variable named __sched_schedstats. Because __sched_schedstats defaults to false, the scheduling tracking subsystem resides in an inactive state throughout the system boot phase.

Within the Linux kernel, psi_init() serves as the core initialization routine for the Pressure Stall Information (PSI) subsystem. The structural design objective of introducing PSI is to accurately quantify resource-contention compute latency losses across CPU, memory, and I/O domains. PSI describes structural resource deficit conditions through two distinct operational states:

  • SOME: A subset of active tasks are stalled waiting for a specific resource, but the CPU continues to execute alternative non-stalled threads.

  • FULL: Every single non-idle task within the context is simultaneously stalled waiting for that resource, leaving the CPU completely idle or trapped in an unproductive state.

The principal technical task of psi_init() is to construct the underlying statistical architecture required to track these PSI metrics, which encompasses:

  • Creating three dedicated virtual files inside the proc file system at /proc/pressure/cpu, /proc/pressure/memory, and /proc/pressure/io, which exposes real-time stall statistics directly to user space.

  • Allocating the mandatory memory space for the localized pressure tracking daemons (Trackers) assigned to each individual CPU core.

  • Initializing the periodic timer routines responsible for calculating moving averages over explicit exponential windows, specifically mapping avg10, avg60, and avg300 performance slots.

The PSI subsystem is governed by a compilation-time flag; machine code is emitted and the capability is enabled only when the statement CONFIG_PSI=y is appended into the corresponding Makefile. If CONFIG_PSI=m is specified, the compiler generates the psi module as a loadable component but does not import it into memory during bootstrap. If CONFIG_PSI is completely omitted from the build configurations, psi_init() resolves to an empty function block (see the #ifdef CONFIG_PSI conditional section inside the header file git/include/linux/psi.h).

When the compiled PSI code is successfully loaded into memory, the psi_init() function evaluates the state of a global boolean flag named psi_enable to determine whether to energize the tracking engine. If psi_enable evaluates to false, psi_init() utilizes dynamic jump label instructions to cleanly bypass the entire PSI execution block, eliminating unnecessary resource dissipation. The default runtime state of the psi_enable flag is dictated by the compilation configuration switch CONFIG_PSI_DEFAULT_DISABLED. If CONFIG_PSI_DEFAULT_DISABLED is defined in the build properties, the system defaults to keeping the PSI engine disabled.

Furthermore, if control groups support is enabled via CONFIG_CGROUPS, the PSI engine provides granular, fine-grained resource pressure metrics independently for each active cgroup hierarchy (exposed via directory entries such as /sys/fs/cgroup/.../cpu.pressure).

Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com